{extend name="layout/layout" /}

{block name="pagecss"}
<link href="__STATIC__/common/css/bootstrap.css" rel="stylesheet">
<link href="__STATIC__/common/css/component.css" rel="stylesheet">
<link href="__STATIC__/common/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
<div class="row">
    <div class="col-xs-12">
        <div class="box box-success">
            <div class="box-header with-border">
                <h3 class="box-title">小程序上线配置</h3>
                <div class="box-tools">
                    <!--<button class="btn bg-navy btn-sm" data-toggle="tooltip" title="" data-original-title="Back" onclick="history.go(-1);">
                        <i class="fa fa-reply"></i> 返回
                    </button>-->
                </div>
            </div>
            <div class="box-body">
                <form id="form_wx_online" action="{:url('admin/MiniProgram/EditTenantConf')}" class="form-horizontal form">
                        <div class="form-body">
                        <div class="form-group">
                            <lable class="col-md-2 control-label">小程序状态：</lable>
                            <div class="col-md-6 form-control-static">
                                {if condition="$data['businessMiniProgram']['wxStatus'] == 0"}未授权
                                {elseif condition="$data['businessMiniProgram']['wxStatus'] == 10"/}已授权
                                {elseif condition="$data['businessMiniProgram']['wxStatus'] == 2"/}审核中
                                {elseif condition="$data['businessMiniProgram']['wxStatus'] == 4"/}审核通过
                                {else /} <span style="color: red">审核失败<br/>{$data['businessMiniProgram']['auditMsg']}</span>
                                {/if}
                            </div>
                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label">小程序名：</lable>
                            <div class="col-md-6 form-control-static">
                                {$data['authorizerInfo']['authorizer_info']['nick_name']}
                            </div>
                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label">认证主体：</lable>
                            <div class="col-md-6 form-control-static">
                                {$data['authorizerInfo']['authorizer_info']['principal_name']}
                            </div>
                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label">授权时间：</lable>
                            <div class="col-md-6 form-control-static">
                                {$data['businessMiniProgram']['authTime']|date='Y-m-d H:i',###}
                            </div>
                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 col-xs-5 control-label"><span class="required">* </span>小程序授权：</lable>
                            <div class="col-md-6 col-xs-6">
                                {if condition="$data['businessMiniProgram']['wxStatus'] == 0"}
                                <a href="{:url('/MiniProgram/AuthCode')}" target="_blank" class="btn btn-info">授权</a>
                                {else/}
                                <a id="jiebang" target="_blank" class="btn btn-info">解绑</a>
                                <span style="color: red">(注意：解绑必须先去微信小程序后台解除第三方绑定，否则解绑无效)<i class="fa fa-exclamation-circle" style="padding-left: 8px;cursor:pointer" aria-hidden="true"></i></span>
                                {/if}
                            </div>
                        </div>
                            {if condition="$data['businessMiniProgram']['wxStatus'] == 10 || $data['businessMiniProgram']['wxStatus'] == 3"}
                            <div class="form-group">
                                <lable class="col-md-2 col-xs-5 control-label"><span class="required">* </span>小程序提交审核：</lable>
                                <div class="col-md-6 col-xs-6">

                                    <a target="_blank" class="btn btn-info" id="tijiao_shenhe">提交审核</a>

                                </div>
                            </div>
                            {/if}
                            <div class="form-group">
                                <lable class="col-md-2 col-xs-5 control-label"><span class="required">* </span>添加小程序体验者：</lable>
                                <div class="col-md-6 col-xs-6">

                                    <a target="_blank" class="btn btn-info" id="add_experiencer">添加小程序体验者</a>

                                </div>
                            </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label">体验二维码：</lable>

                            <div class="col-md-6 col-xs-6">
                                <a href="javascript:;" class="md-trigger btn btn-primary btn-sm" data-modal="modal-7">查看</a>


                                <div class="md-modal md-effect-7" id="modal-7">
                                    <div class="md-content">
                                        <h3>体验二维码</h3>
                                        <div>
                                            <p>这是小程序体验二维码，请用微信扫描</p>
                                            <img src="{$qrcode}">
                                        </div>
                                    </div>
                                </div>


                                <div class="md-overlay"></div>
                            </div>

                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label"><span class="required">* </span>商户支付号：</lable>
                            <div class="col-md-6">
                                <input type="text" class="form-control" maxlength="40" required value="{$data['businessMiniProgram']['mchId']}" name="mchId">

                            </div>
                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label"><span class="required">* </span>商户支付密钥：</lable>
                            <div class="col-md-6">
                                <input type="text" class="form-control" maxlength="70" required value="{$data['businessMiniProgram']['mchKey']}" name="mchKey">
                            </div>
                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label"><span class="required">* </span>商户API证书：</lable>
                            <div class="col-lg-6">
                                <input id="file_upload_cert" type="file" class="form-control" min="0" multiple="true" maxlength="5"  value="">

                                <input id="file_upload_image_cert" name="certfile" type="hidden" class="form-control" maxlength="40" multiple="true" value="{$data['businessMiniProgram']['certfile']}">
                                <input id="file_upload_image_cert_show" type="text" class="form-control" maxlength="40" disabled="disabled" multiple="true" value="{$data['businessMiniProgram']['certfile']}">
                            </div>
                            <div class="col-md-4">
                            </div>

                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label"><span class="required">* </span>商户API证书密钥：</lable>
                            <div class="col-lg-6">
                                <input id="file_upload_key" type="file" class="form-control" min="0" multiple="true" maxlength="5"  value="">

                                <input id="file_upload_image_key" name="certkey" class="form-control" maxlength="40" type="hidden" multiple="true" value="{$data['businessMiniProgram']['certkey']}">
                                <input id="file_upload_image_key_show" class="form-control" maxlength="40" type="text" disabled="disabled" multiple="true" value="{$data['businessMiniProgram']['certkey']}">
                            </div>
                            <div class="col-md-4">
                            </div>

                        </div>
                        <div class="form-group">
                            <lable class="col-md-2 control-label">特别提示：</lable>
                            <div class="col-md-6 form-control-static">
                                <ul>
                                    <li class="m-t">一个小程序账号只能和一个店铺绑定。</li>
                                    <li class="m-t">小程序升级后，请注意图片、描述等方面的变化。</li>
                                    <li class="m-t">企业的小程序账号必须认证后，才可以授权托管。</li>
                                    <li class="m-t" style="color: red">请确保小程序的服务类目与页面内容一致，（提交审核之前去小程序后台检查服务类目）否则无法通过微信审核<i class="fa fa-question-circle" style="padding-left: 8px;cursor:pointer" aria-hidden="true"></i></li>
                                    <li class="m-t">目前小程序只支持微信自有支付，请确保在「小程序后台 - 微信支付」页面下申请开通并完成相关配置。</li>
                                    <li class="m-t">微信支付审核通过后，微信会将商户号发送到接收邮箱，请在微信商户后台账号设置－API安全进行密钥设置。</li>
                                    <li class="m-t">请确认商户号和用户密钥配置填写正确（否则将导致微信支付异常，小程序无法通过审核）。</li>
                                </ul>
                            </div>
                        </div>

                        <hr />

                        <div class="form-actions">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-md-3 control-label"></label>
                                        <div class="col-md-9">
                                            <button type="button" id="btn_new_role" class="btn btn-primary">
                                                保存 <i class="fa fa-floppy-o"></i>
                                            </button>
                                            <span class="help-block "></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    </form>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="pagescript"}
<script>
    swf = '__STATIC__/common/uploadify/uploadify.swf'
    image_upload_url = "{:url('/admin/Uploadfile/uploadcertFile')}"
</script>
<script src="__STATIC__/admin/js/include.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/wxOnline.js" type="text/javascript"></script>
<script src="__STATIC__/common/js/classie.js" type="text/javascript"></script>
<script src="__STATIC__/common/js/modalEffects.js" type="text/javascript"></script>
<script src="__STATIC__/common/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<script src="__STATIC__/common/js/cert.js" type="text/javascript"></script>
<script type="text/javascript">
    function member_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    $('#tips').on('click', function() {

    });
    $('#tijiao_shenhe').on('click',function() {

        var tijiaonums = "{$tijiaonums}";
        var shengyus  = "{$shengyunums}";
        layer.open({
            type: 1
            ,title: "特别提示" //不显示标题栏   title : false/标题
            ,closeBtn: true
            ,area: '400px;'
            ,shade: 0.6
            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
            ,resize: false
            ,btn: ['确定提交', '取消']
            ,btnAlign: 'c'
            ,moveType: 1 //拖拽模式，0或者1
            ,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;"><span style="color: #fff;font-weight: 900">特别注意：提交审核之前请确保小程序的服务类目与小程序页面内容一致！否则导致腾讯审核不通过！</span><br/><a href="https://mp.weixin.qq.com/" target="_blank">去小程序后台</a><br/><br/>微信官方提示：一周之内只能提交5次审核<br/>本周已提交审核：'+tijiaonums+'次<br/>本周剩余：'+shengyus+'次<br/><br/>审核时间为1-7个工作日，请耐心等待！</div>'
            ,success: function(layero){
                var btn = layero.find('.layui-layer-btn');
                btn.find('.layui-layer-btn0').click(function(){

                    $.ajax({
                        url : '/admin/MiniProgram/onedemosubmissionaudit',
                        type : 'post',
                        dataType : 'json',
                        contentType:"application/json; charset=utf-8",
                        async: false,
                        data : {},
                    }).done(function(r) {
                        if (r.status == '1') {
                            layer.msg(r.message, {icon: 6, time: 3000});
                            window.location.reload();
                        } else if (r.status == '0') {
                            layer.msg(r.message, {icon: 5, time: 3000});
                            $('#myModal2').modal('hide');
                        }
                    });
                });
            }
        });
    });

    $('#jiebang').on('click',function() {
        layer.open({
            type: 1
            ,title: "提示" //不显示标题栏   title : false/标题
            ,closeBtn: true
            ,area: '300px;'
            ,shade: 0.6
            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
            ,resize: false
            ,btn: ['确定', '取消']
            ,btnAlign: 'c'
            ,moveType: 1 //拖拽模式，0或者1
            ,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">注意：解绑之前必须先去小程序后台解除第三方绑定！<a href="https://mp.weixin.qq.com/" target="_blank">去小程序后台</a><br/>解绑之后将无法访问小程序，<br/>请谨慎操作！！</div>'
            ,success: function(layero){
                var btn = layero.find('.layui-layer-btn');
                btn.find('.layui-layer-btn0').click(function(){

                    var url = "/admin/MiniProgram/wechatjiebang";
                    $.ajax({
                        type: 'POST',
                        url: url,
                        dataType: 'json',
                        success: function(data){
                            if(data.status == '1'){
                                layer.alert(data.message,{icon: 6});
                                location.reload();
                            }else {
                                layer.alert(data.message,{icon: 5});
                            }

                        },
                        error:function(data) {
                            console.log(data.msg);
                        },
                    });
                });
            }
        });
    });
    $('#add_experiencer').on('click',function() {
        layer.prompt({title:'请输入体验者微信号'},function(val,index){
            var url='http://upa.kuman.cn/finance/tus';
            $.ajax({
                url : '/admin/MiniProgram/addexperiencer?wechat_id=' + val,
                type : 'get',
                dataType : 'json',
                contentType : "application/json; charset=utf-8",
                data : {},
            }).done(function(data) {
                if (data.status == 1) {
                    layer.msg(data.message);
                    //window.location.href= data.url; //加载页面数据
                } else if (data.status == 0 ) {  // 错误
                    $("#form-submit").removeAttr("disabled");
                    layer.msg(data.message);
                }
            });
            layer.close(index);
            //window.parent.location.reload();
        });

    });
    $('.fa-question-circle').on('click',function() {
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
            area: ['1200px', '635px'], //宽高
            content: '<img width="1200" src="/public/static/admin/img/help.png" />'
        });
    });
    $('.fa-exclamation-circle').on('click',function() {
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
            area: ['1200px', '635px'], //宽高
            content: '<img width="1200" src="/public/static/admin/img/help01.png" />'
        });
    })

</script>
{/block}